<?php
defined('_VALID_MOS') or die(include_once("../../404.php"));
$sql = "SELECT `product`.`Id`, `product`.`name`, `product`.`image_file`
		FROM `product`
		WHERE `activated` = 1
		order by `product`.`order_num` desc";
$cmd = $mysqli->prepare($sql);
$cmd->execute();
$cmd->bind_result($Id, $name, $image_file);
$cmd->store_result();
$i = 1;
?>
<div id="box_khung_sanpham">
    <div class="tt_right"><div class="tt_left"><div class="tt">Sản phẩm </div></div></div>
    <div id="sub_box_khung_sanpham">
        <div id="sub_box_khung_sanpham1">
            <div class="ct_right"><div class="ct_left">
                    <div class="ct">
                        <table>
                            <tr>
                                <td>
                                    <div id="box_sanpham_top">
                                        <div class="sp_tt_right"><div class="sp_tt_left"><div class="sp_tt"></div></div></div>
                                        <div id="sp_sub_box_sanpham">
                                            <div class="sp_ct_right"><div class="sp_ct_left">
                                                    <div class="sp_ct">
                                                        <ul>
                                                            <?php
                                                            $cmd->fetch();
                                                            echo "<li><a class=image href=\".?com=com_product&view=detail&id=$Id\"><img class=imageFader src=\"$image_file\"></a></li>";
                                                            echo "<li><a class=label href=\".?com=com_product&view=detail&id=$Id\">$name</a></li>";
                                                            ?>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="sp_bt_right"><div class="sp_bt_left"><div class="sp_bt"></div></div></div>								
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                </td>
                                <td>
                                    <div id="box_sanpham_top">
                                        <div class="sp_tt_right"><div class="sp_tt_left"><div class="sp_tt"></div></div></div>
                                        <div id="sp_sub_box_sanpham">
                                            <div class="sp_ct_right"><div class="sp_ct_left">
                                                    <div class="sp_ct">
                                                        <ul>
                                                            <?php
                                                            $cmd->fetch();
                                                            echo "<li><a class=image href=\".?com=com_product&view=detail&id=$Id\"><img class=imageFader src=\"$image_file\"></a></li>";
                                                            echo "<li><a class=label href=\".?com=com_product&view=detail&id=$Id\">$name</a></li>";
                                                            ?>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="sp_bt_right"><div class="sp_bt_left"><div class="sp_bt"</div></div></div>								
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <div id="box_sanpham_top">
                                        <div class="sp_tt_right"><div class="sp_tt_left"><div class="sp_tt"></div></div></div>
                                        <div id="sp_sub_box_sanpham">
                                            <div class="sp_ct_right"><div class="sp_ct_left">
                                                    <div class="sp_ct">
                                                        <ul>
                                                            <?php
                                                            $cmd->fetch();
                                                            echo "<li><a class=image href=\".?com=com_product&view=detail&id=$Id\"><img class=imageFader src=\"$image_file\"></a></li>";
                                                            echo "<li><a class=label href=\".?com=com_product&view=detail&id=$Id\">$name</a></li>";
                                                            ?>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="sp_bt_right"><div class="sp_bt_left"><div class="sp_bt"></div></div></div>								
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                </td>							
                            </tr>
                        </table>

                        <table width="100%">
                            <tr>
                                <td colspan="3"><div id="bg_sp_orther">Các loạl vỏ bao đựng xi măng tiêu biểu</div></td>
                            </tr>	
                            <tr>							
                                <?php
                                while ($cmd->fetch()) {
                                    if ($i % 3 == 0) {
                                        echo "<td align=center>
												<div id=box_sanpham_bottom>
												<div class=sp_tt_right><div class=sp_tt_left><div class=sp_tt></div></div></div>
												<div id=sp_sub_box_sanpham>
													<div class=sp_ct_right><div class=sp_ct_left>
														<div class=sp_ct>
															<ul>
																<li><a class=image href=\".?com=com_product&view=detail&id=$Id\"><img class=imageFader src=\"$image_file\"></a></li>
																<li><a class=label href=\".?com=com_product&view=detail&id=$Id\">$name</a></li>
															</ul>
														</div>
													</div>
													</div>
													<div class=sp_bt_right><div class=sp_bt_left><div class=sp_bt></div></div></div>								
												</div>
												<div class=clear></div>
											</div>
										</td>";
                                        echo "</tr>";
                                        echo "<table width=100%>";
                                        echo "<tr>";
                                    }
                                    else {
                                        echo "<td align=center>
											<div id=box_sanpham_bottom>
											<div class=sp_tt_right><div class=sp_tt_left><div class=sp_tt></div></div></div>
											<div id=sp_sub_box_sanpham>
												<div class=sp_ct_right><div class=sp_ct_left>
													<div class=sp_ct>
														<ul>
															<li><a class=image href=\".?com=com_product&view=detail&id=$Id\"><img class=imageFader src=\"$image_file\"></a></li>
															<li><a class=label href=\".?com=com_product&view=detail&id=$Id\">$name</a></li>
														</ul>
													</div>
												</div>
												</div>
												<div class=sp_bt_right><div class=sp_bt_left><div class=sp_bt></div></div></div>								
											</div>
											<div class=clear></div>
										</div>
									</td>";
                                    }
                                    $i++;
                                }
                                ?>

                            </tr>						
                        </table>
                    </div>
                </div>											
            </div>
            <div class="bt_right"><div class="bt_left"><div class="bt"></div></div></div>								
        </div>
    </div>
    <div class="clear"></div>
</div>